import 'package:flutter/material.dart';

class SliverDemo extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return CustomScrollView(
      slivers: [
        SliverAppBar(
          pinned: true,
          floating: true, // 向下滑动的时候，优先显示
          expandedHeight: 178,

          flexibleSpace: FlexibleSpaceBar(
            title: Text("标准title"),
            collapseMode: CollapseMode.none,
            background: Image.network("https://img0.baidu.com/it/u=1197219205,4137252383&fm=253&fmt=auto&app=120&f=JPEG?w=655&h=1417",fit: BoxFit.cover,),
          ),

          title: Text("sliverAppBar title"),
        ),


        SliverGrid.count(

          crossAxisCount: 3,
          children: _bulidGridItem(),
          mainAxisSpacing: 10,
          crossAxisSpacing: 10,
        ),
        SliverList.list(children: _bulidGridItem())
      ],
    );
  }


  Widget _bulidSliverPadding() {
    return SliverSafeArea(sliver: SliverPadding(

      padding: EdgeInsets.all(20),
      sliver: SliverGrid.count(
        crossAxisCount: 3,
        children: _bulidGridItem(),
        mainAxisSpacing: 10,
        crossAxisSpacing: 10,
      ),
    ));
  }

  List<Widget> _bulidGridItem() {
    return List<Widget>.generate(40, (int index) {
      return Container(color: Colors.grey);
    });
  }
}
